package com.revenant.driver.ui.activity;

import android.os.Bundle;
import android.util.Log;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.revenant.driver.R;
import com.revenant.driver.base.BaseActivity;
import com.revenant.driver.bean.WebUrlBean;
import com.revenant.driver.utils.GsonUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import wendu.dsbridge.DWebView;

import static com.revenant.driver.utils.Constants.Look_Xieyi;
import static com.revenant.driver.utils.Constants.User_Send_Verification_Code;
import static com.revenant.driver.utils.Constants.isProOrTest;

public class WebContentActivity extends BaseActivity {
    @BindView(R.id.webtest)
    DWebView webtest;
    private String testpro = "http://web.cltkj.net//clt-wallet/privacypolicy.html";
    private String testurl = "http://web.cltkj.net//clt-wallet/privacypolicy.html";

    private String WebTest = (isProOrTest) ? testpro : testurl;
    ;
    private String weburl = "";
    @Override
    public int getContentViewResId() {
        return R.layout.activity_web_content;
    }

    @Override
    public void initView() {
        setcenterTitle("用户协议");

    }

    @Override
    public void leftbarclick() {
        finish();
    }

    @Override
    public void initData() {
        getXieyi(1);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    private void getXieyi(int status){
        OkGo.<String>post(Look_Xieyi)
                .params("status", status)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        WebUrlBean webUrlBean = GsonUtil.parseJsonWithGson(response.body(), WebUrlBean.class);
                        if (webUrlBean.getCode().contains("0")) {
                            weburl = webUrlBean.getData().getUrl();
                            webtest.loadUrl(weburl);
                        }

                    }
                });
    }
}
